<?php

declare(strict_types=1);

namespace App\Listener;

use Hyperf\ConfigCenter\Event\ConfigChanged;
use Hyperf\Context\ApplicationContext;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Logger\LoggerFactory;

#[Listener]
class ConfigChangedListener implements ListenerInterface
{
    public function listen(): array
    {
        return [
            ConfigChanged::class
        ];
    }

    /**
     * 远程配置发生变化时触发事件
     */
    public function process(object $event): void
    {
        ApplicationContext::getContainer()->get(LoggerFactory::class)->get('config')->info('Config changed.');
    }
}
